/* 
 * AgenteBusinessImpl.java
 * 
 * Data de criação: 25/10/2010
 * 
 * CORPORATIVO - MTE. 
 *
 */
package br.com.o2solutions.siso.business.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Value;

import br.com.o2solutions.core.aop.business.annotation.ApplyRule;
import br.com.o2solutions.core.aop.business.annotation.Business;
import br.com.o2solutions.core.business.BasicBusinessSupport;
import br.com.o2solutions.core.exception.BusinessException;
import br.com.o2solutions.core.exception.enumerator.ExceptionScope;
import br.com.o2solutions.core.integration.repository.DataBaseIntegration;
import br.com.o2solutions.siso.business.AgenteBusiness;
import br.com.o2solutions.siso.business.rule.agente.AgenteInsertUpdateRule;
import br.com.o2solutions.siso.integration.entidade.Agente;
import br.com.o2solutions.util.assertion.Assert;

/**
 * Classe responsável por implementar a interface {@link AgenteBusiness}.
 * 
 * @author Osvaldeir
 * @since 25/10/2010
 * 
 */
@Business("agenteBusiness")
public class AgenteBusinessImpl extends BasicBusinessSupport<Agente> implements
		AgenteBusiness {

	@Override
	@Value("#{agenteDAO}")
	public void setDataBaseIntegration(
			DataBaseIntegration<Agente> dataBaseIntegration) {
		super.setDataBaseIntegration(dataBaseIntegration);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void verificarExistenciaAgente(Agente agente)
			throws BusinessException {
		if (agente == null)
			return;
		List<Agente> findByCriterio = getDataBaseIntegration().findByCriterio(
				agente);
		Assert.notEmpty(findByCriterio, new BusinessException(
				"Agente não encontrado", "error.agente.null",
				ExceptionScope.BUSINESS_PROCCESS));
	}
	
	@Override
	@ApplyRule(rules = AgenteInsertUpdateRule.class)
	public void save(Agente entity) throws BusinessException {
		// TODO Auto-generated method stub
		super.save(entity);
	}
	
	@Override
	@ApplyRule(rules = AgenteInsertUpdateRule.class)
	public void update(Agente entity) throws BusinessException {
		// TODO Auto-generated method stub
		super.update(entity);
	}

}
